﻿@model Bricks.Site.Models.ProjectContractView
@{
    ViewBag.Title = "AddAterOrderBill";
    Layout = "~/Views/Shared/_UserPage.cshtml";
}

<head>
    <title></title>
    <script type="text/javascript">
        function SaveData() {
            var BillCode = $("#BillCode").val();
            var BillName = $("#BillName").val();
            var Unit = $("#Unit").val();
            var Price = $("#Price").val();
            var OriginalCount = $("#OriginalCount").val();
            var AfterAlterCount = $("#AfterAlterCount").val();
            var Remark = $("#Remark").val();
            if (BillCode == '' || Unit == '' || Price == '') {
                $.messager.alert('操作提示', '清单号、单位和单价不能为空！', 'info');
                return;
            }

            if (!window.parent.ValidateAddData(BillCode)) {
                $.messager.alert('操作提示', '已经存在该清单号！', 'info');
                return;
            }
            else {
                var AlterCount = '';
                var AlterMoney = '';
                if (OriginalCount != '' || AfterAlterCount != '') {
                    if (OriginalCount != '') {
                        if (AfterAlterCount != '') {
                            AlterCount = AfterAlterCount - OriginalCount;
                        }
                        else {
                            AlterCount = -OriginalCount;
                        }
                    }
                    else {
                        AlterCount = AfterAlterCount;
                    }
                }
                if (AlterCount != '') {
                    var AlterMoney = Math.round((AlterCount) * Price)
                    if (AlterMoney > 999999999999) {
                        $.messager.alert('操作提示', '增减金额：999999999999！', 'info');
                        return;
                    }
                }
                window.parent.CloseWindow(0);
                window.parent.SetAddReturnValue(BillCode, BillName, Unit, Price, OriginalCount, AfterAlterCount,AlterCount,AlterMoney, Remark);
            }
        }
    </script>
</head>
<body>
    <div style="padding:5px;">
        <input type="hidden" id="hContractID" name="ContractID" value="@Model.ContractID" />
        <div region="top" style="height:140px;">
            <table style="margin: 1px">
                <tr>
                    <td style="width: 110px; text-align: right">清单号</td>
                    <td>
                        <input name="BillCode" id="BillCode" class="easyui-textbox" data-options="required:true" style="width: 190px;" />
                    </td>
                    <td style="width: 110px; text-align: right; ">清单名称</td>
                    <td>
                        <input id="BillName" name="BillName" class="easyui-textbox" data-options="required:true" style="width: 190px; " />
                    </td>
                </tr>
                <tr>
                    <td style="width: 110px; text-align: right">单位</td>
                    <td>
                        <input name="Unit" id="Unit" class="easyui-textbox" data-options="required:true" style="width: 190px; " />
                    </td>
                    <td style="width: 110px; text-align: right">单价</td>
                    <td>
                        <input name="Price" id="Price" class="easyui-numberbox" data-options="min: 0, max: 99999999.999, precision: 3" style="width: 190px; " />
                    </td>
                </tr>
                <tr>
                    <td style="width: 110px; text-align: right">原数量</td>
                    <td>
                        <input name="OriginalCount" id="OriginalCount" class="easyui-numberbox" data-options="min: 0, max: 99999999.999, precision: 3" style="width: 190px; " />
                    </td>
                    <td style="width: 110px; text-align: right">变更后数量</td>
                    <td>
                        <input id="AfterAlterCount" name="AfterAlterCount" class="easyui-numberbox" data-options="min: 0, max: 99999999.999, precision: 3" style="width: 190px; " />
                    </td>
                </tr>
                <tr>
                    <td style="width: 110px; text-align: right">备注</td>
                    <td colspan="3">
                        <input name="Remark" id="Remark" class="easyui-textbox" data-options="required:true" style="width: 490px;" />
                    </td>
                </tr>
            </table>
        </div>
        <div style="margin-left: 5px; margin-top: 5px; text-align: right;">
            <input type="button" id="btnSave" value="确定" onclick="SaveData();" />
            <input type="button" id="btnCancel" value="取消" onclick="window.parent.CloseWindow(0);" />
        </div>
    </div>
</body>
